{extend name="public/layout" /}
{block name="body"}
    <form class="layui-form" > <!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
        <div class="layui-card pd-bt-15">
            <div class="layui-row">
                <div class="layui-col-md8">
                    <div class="layui-form-item">
                        <label class="layui-form-label">标签名字</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" value="{$vo.name|default=''}" lay-verify="required"  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-col-md4">
                    <div class="layui-form-mid layui-word-aux">请输入权限名字</div>
                </div>
            </div>

            {if condition="isset($is_update) && $is_update eq 1"}
                <input type="hidden" name="id" value="{$vo.id}"/>
            {/if}
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="*">立即提交</button>
                </div>
            </div>
        </div>
    </form>
{/block}
{block name="script"}
    <script>
        layui.use('form',function(){
            var form = layui.form,
                $ = layui.$;
            form.on('submit(*)', function(data){
                {if condition="isset($is_update) && $is_update eq 1"}
                var url =  "{:url('update')}";
                {else/}
                var url =  "{:url('add')}";
                {/if}
                $.post(url,data.field,function(data){
                    if(data.code == 10000)
                    {
                        layer.msg(data.msg,{icon:1,time:1500},function(){
                            window.location.href = "{:url('index')}";
                        })
                    }else{
                        layer.msg(data.msg,{icon:2,time:1500})
                    }

                });
                return false;
            });

        });
    </script>
{/block}